package com.yao.dao.impl;

import com.yao.dao.ArticleDao;
import com.yao.entity.Article;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class ArticleDaoImpl implements ArticleDao {

    //获取JdbcTemplate对象
    @Autowired
    private JdbcTemplate jdbcTemplate;

    /**
     * 添加文章信息
     * @param article
     */
    public void saveArticle(Article article) {

        //向t_article表添加信息
        String sql = "insert into t_article values (?, ?, ?)";
        //添加信息
        jdbcTemplate.update(sql, article.getId(), article.getTitle(), article.getContent());

    }
}
